import fetch from 'common/src/utils/fetch';
import baseUrl from './env';
import UTILS from "common/src/utils/utils";
import {
  param
} from 'common/src/utils';
import axios from 'axios';


// 获取项目类别下拉框
function getProjectType() {
  return fetch({
    url: `${baseUrl}/roleManage/getProjectType`,
    method: 'get',
  });
}

// 获取角色分类下拉框
function getRoleList() {
  return fetch({
    url: `${baseUrl}/roleManage/getRoleList`,
    method: 'get',
  });
}
 
// 新增特殊角色
function addRole(data) {
  return fetch({
    url: `${baseUrl}/roleManage/addRole`,
    method: 'Post',
    data
  });
}

// 根据工号模糊搜索用户信息
function getInfoById(data) {
  return fetch({
    url: `${baseUrl}/roleManage/getInfoById?id=`+ data,
    method: 'get',
    data
  });
}

// 列表
function getList(data) {
  return fetch({
    url: `${baseUrl}/roleManage/getList`,
    method: 'Post',
    data
  });
}

// 修改特殊角色
function editRole(data) {
  return fetch({
    url: `${baseUrl}/roleManage/editRole`,
    method: 'Post',
    data
  });
}

// 删除特殊角色
function deleteRole(data) {
  return fetch({
    url: `${baseUrl}/roleManage/deleteRole`,
    method: 'Post',
    data
  });
}

// 下载导入模板
function downloadTemplate(data) {
  return fetch({
    url: `${baseUrl}/sysDictionary/downFile?path=` + data,
    method: 'get',
    responseType: 'blob',
    data
  }).then(res => {
    UTILS.downloadFile(res, '导入模板.xlsx', 'application/vnd.ms-excel;charset=utf-8');
  });
}

// 删除特殊角色
function downLoad(data) {
  return fetch({
    url: `${baseUrl}/roleManage/downloadGeneratedTemplate`,
    method: 'Post',
    data
  });
}

// 删除特殊角色
function downFile(data) {
  return fetch({
    url: `${baseUrl}/sysDictionary/downFile?path=` + data,
    method: 'get',
    data
  });
}

export default {
  'getProjectType': getProjectType,
  'getRoleList': getRoleList,
  'addRole': addRole,
  'getInfoById': getInfoById,
  'getList': getList,
  'editRole': editRole,
  'deleteRole': deleteRole,
  'downloadTemplate': downloadTemplate,
  'downLoad': downLoad,
  'downFile': downFile

};
